
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Leo Nodejs SDK
A Nodejs interface to interact with the Leo Platform
Quick Start Guide: https://github.com/LeoPlatform/Leo
Documentation: https://docs.leoplatform.io
npm install leo-sdk
To load data onto the bus on AWS, you need to have a valid leo_config.js file. If you don't have one already, the easiest way to create one is to create a quickstart project and let the system configure the AWS settings for you.
Note: If you're using the SDK within a microservice, we bootstrap the config for you, otherwise you'll have to specify the path to your leo_config.js.
Bash example:
export leo_config_bootstrap_path='/path/to/leo_config.js'
Javascript example:
process.env.leo_config_bootstrap_path = '/path/to/leo_config.js';
Next, you'll have to make sure your NODE_ENV matches the environment configured in leo_config.js.
Now you can write to the new Stream:
let leo = require("leo-sdk");
let botId = "producerBotId";
let queueName = "queueName";
let stream = leo.load(botId, queueName);
// Write 10 events to the leo bus
for (let i = 0; i < 10; i++) {
stream.write({
now: Date.now(),
index: i,
number: Math.round(Math.random() * 10000)
});
}
stream.end(err=>{
console.log("All done loading events", err);
});
Next in order to read from the stream
let leo = require("leo-sdk");
let botId = "offloadBotId";
let queueName = "queueName";
leo.offload({
id: botId,
queue: queueName,
each: (payload, meta, done) =>{
console.log(payload);
console.log(meta);
done(null, true); // Report this event was handled
}
}, (err)=>{
console.log("All done processing events", err);
});
You can also enrich from one queue to another
let leo = require("leo-sdk");
let botId = "enrichBotId";
let inQueueName = "queueName";
let outQueueName = "enrichedQueueName";
leo.enrich({
id: botId,
inQueue: inQueueName,
outQueue:outQueueName,
// optional batch parameter:
batch: 50, // batch every 50 records, or:
// optional batch as object with optional parameters:
batch: {
count: 50, // batch every 50 records, or:
bytes: 500, // batch every 500 bytes, or:
time: 1000, // batch every 1000 milliseconds (1 second)
},
each: (payload, meta, done) =>{
// Add new data to the event payload
done(null, Object.assign({
enriched: true,
numberTimes2: payload.number * 2,
enrichedNow: Date.now()
}, payload));
}
}, (err)=>{
console.log("All done processing events", err);
});
Want to hire an expert, or need technical support? Reach out to the Leo team: https://leoinsights.com/contact
FAQs
Load data onto the LEO Platform
The npm package leo-sdk receives a total of 655 weekly downloads. As such, leo-sdk popularity was classified as not popular.
We found that leo-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.